import '../helper/dioHelper2.dart';

class ShuiZhi {
  int ID;
  String STATIONID;
  String BASINNAME;
  String CHECKLEVER;
  String STATIONNAME;
  String TARGETWATER;
  String RIVERNAME;
  String LATITUDE;
  String LONGITUDE;
  String CWQI;
  String COL1;
  String COL1_CWQI;
  String COL2;
  String COL2_CWQI;
  String COL3;
  String COL3_CWQI;
  String COL4;
  String COL4_CWQI;
  String COL6;
  String COL6_CWQI;
  String COL11;
  String COL12;
  String COL14;
  String COL15;
  String COL19;
  String COL23;
  String COL49;
  String PUBLISHTIME;
  String NOREACHFACTS;

  ShuiZhi(
      this.ID,
      this.STATIONID,
      this.BASINNAME,
      this.CHECKLEVER,
      this.STATIONNAME,
      this.TARGETWATER,
      this.RIVERNAME,
      this.LATITUDE,
      this.LONGITUDE,
      this.CWQI,
      this.COL1,
      this.COL1_CWQI,
      this.COL2,
      this.COL2_CWQI,
      this.COL3,
      this.COL3_CWQI,
      this.COL4,
      this.COL4_CWQI,
      this.COL6,
      this.COL6_CWQI,
      this.COL11,
      this.COL12,
      this.COL14,
      this.COL15,
      this.COL19,
      this.COL23,
      this.COL49,
      this.PUBLISHTIME,
      this.NOREACHFACTS);
  ShuiZhi.fromJson(Map<String, dynamic> json)
      : ID = json["ID"],
        STATIONID = json["STATIONID"],
        BASINNAME = json["BASINNAME"],
        CHECKLEVER = json["CHECKLEVER"],
        STATIONNAME = json["STATIONNAME"],
        TARGETWATER = json["TARGETWATER"],
        RIVERNAME = json["RIVERNAME"],
        LATITUDE = json["LATITUDE"],
        LONGITUDE = json["LONGITUDE"],
        CWQI = json["CWQI"],
        COL1 = json["COL1"],
        COL1_CWQI = json["COL1_CWQI"],
        COL2 = json["COL2"],
        COL2_CWQI = json["COL2_CWQI"],
        COL3 = json["COL3"],
        COL3_CWQI = json["COL3_CWQI"],
        COL4 = json["COL4"],
        COL4_CWQI = json["COL4_CWQI"],
        COL6 = json["COL6"],
        COL6_CWQI = json["COL6_CWQI"],
        COL11 = json["COL11"],
        COL12 = json["COL12"],
        COL14 = json["COL14"],
        COL15 = json["COL15"],
        COL19 = json["COL19"],
        COL23 = json["COL23"],
        COL49 = json["COL49"],
        PUBLISHTIME = json["PUBLISHTIME"],
        NOREACHFACTS = json["NOREACHFACTS"];
  Map<String, dynamic> toJson() => {
        'ID': ID,
        'STATIONID': STATIONID,
        'BASINNAME': BASINNAME,
        'CHECKLEVER': CHECKLEVER,
        'STATIONNAME': STATIONNAME,
        'TARGETWATER': TARGETWATER,
        'RIVERNAME': RIVERNAME,
        'LATITUDE': LATITUDE,
        'LONGITUDE': LONGITUDE,
        'CWQI': CWQI,
        'COL1': COL1,
        'COL1_CWQI': COL1_CWQI,
        'COL2': COL2,
        'COL2_CWQI': COL2_CWQI,
        'COL3': COL3,
        'COL3_CWQI': COL3_CWQI,
        'COL4': COL4,
        'COL4_CWQI': COL4_CWQI,
        'COL6': COL6,
        'COL6_CWQI': COL6_CWQI,
        'COL11': COL11,
        'COL12': COL12,
        'COL14': COL14,
        'COL15': COL15,
        'COL19': COL19,
        'COL23': COL23,
        'COL49': COL49,
        'PUBLISHTIME': PUBLISHTIME,
        'NOREACHFACTS': NOREACHFACTS,
      };
  static Future<bool> Add(ShuiZhi x1) async {
    var response = await DioHelper.Post("/ShuiZhi/Add", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Update(ShuiZhi x1) async {
    var response = await DioHelper.Post("/ShuiZhi/Update", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<bool> Delete(ShuiZhi x1) async {
    var st = x1.toJson();
    var response = await DioHelper.Post("/ShuiZhi/Delete", x1.toJson());
    if (response.statusCode == 200) return true;
    return false;
  }

  static Future<ShuiZhi?> Get(String where, dynamic data) async {
    var response = await DioHelper.Post("/ShuiZhi/GetByWhere", {
      "Where": where,
      "obj": data,
    });

    if (response.statusCode == 200) return new ShuiZhi.fromJson(response.data);
    return null;
  }

  static Future<ShuiZhi?> GetNew() async {
    var response = await DioHelper.Get("/SdzxData/GetZData", {});

    if (response.statusCode == 200) return new ShuiZhi.fromJson(response.data);
    return null;
  }

  static Future<List<ShuiZhi>> GetList(
      String where, dynamic data, int pageIndex, int pageSize) async {
    var response = await DioHelper.Post("/ShuiZhi/GetListByWhere", {
      "Where": where,
      "obj": data,
      "PageIndex": pageIndex,
      "PageSize": pageSize,
    });
    var list1 = <ShuiZhi>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new ShuiZhi.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<ShuiZhi>> GetAllList() async {
    var response = await DioHelper.Get("/ShuiZhi/GetAllList", {});
    var list1 = <ShuiZhi>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new ShuiZhi.fromJson(x));
      }
    }
    return list1;
  }

  static Future<List<ShuiZhi>> GetListByTM(String snm, t1, t2) async {
    var response = await DioHelper.Get(
        "/SdzxData/GetZListByTM?sID=" + snm + "&TM1=" + t1 + "&TM2=" + t2, {});
    var list1 = <ShuiZhi>[];
    if (response.statusCode == 200) {
      for (var x in response.data) {
        list1.add(new ShuiZhi.fromJson(x));
      }
    }
    return list1;
  }
}
